mini.parse();
var projectName = $("#projectName").val();
var form = new mini.Form("form1");
var orgId = '';
var contractNo = ''; //合同号,用于加载该合同所包含的设备
function SaveData() {
    form.validate();
    if (form.isValid() == false) return;
    var json = GetData();
    CloseWindow(json);
}

////////////////////
//标准方法接口定义
function CheckEventSubTable(data) {
    //跨页面传递的数据对象，克隆后才可以安全使用
    data = mini.clone(data);
    if (data.action == "edit") {
        SetData(data);
    } else if (data.action == "new") {} else if (data.action == "look") {
        SetData(data);
    }
}

function GetData() {
    var o = form.getData();
    return o;
}

function SetData(data) {
	var data1 =mini.clone(data);
	form.setData(data1);
}

function CloseWindow(action) {
    console.log(action);
    if (action == "close" && form.isChanged()) {
        if (confirm("数据被修改了，是否先保存？")) {
            return false;
        }
    }
    if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
    else window.close();
}

function onOkSubTable(e) {
	SaveData();
}

function onCancelSubTable(e) {
    CloseWindow("cancel");
}

function labelModel() {
    var fields = form.getFields();
    for (var i = 0,
    l = fields.length; i < l; i++) {
        var c = fields[i];
        if (c.setReadOnly) c.setReadOnly(true); //只读
        if (c.setIsValid) c.setIsValid(true); //去除错误提示
        if (c.addCls) c.addCls("asLabel"); //增加asLabel外观
    }
}
function inputModel() {
    var fields = form.getFields();
    for (var i = 0,
    l = fields.length; i < l; i++) {
        var c = fields[i];
        if (c.setReadOnly) c.setReadOnly(false);
        if (c.removeCls) c.removeCls("asLabel");
    }
    mini.repaint(document.body);
}
function readOnlyForm() {
    $("#button_okSubTable").hide();
    $("#button_onSubTable").hide();
    form.setEnabled(false);
}

/**设备类型改变事件*/
function onEqTypeChanged(e) {
    var eq_type_id = this;
    mini.get("EQ_TYPE_NAME").setValue(eq_type_id.getText());
}

